<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<title>鼓励金营销</title>
		<link rel="stylesheet" href="__AGENT__/css/iconfont.css" />
		<link rel="stylesheet" href="__AGENT__/css/css.css" />
		<style type="text/css">
			.layui-form-switch{margin-top: 0!important;}
			.layui-form-onswitch{border-color: #FF7831!important; background-color: #FF7831!important;}
		</style>
	</head>

	<body>
		
		
		{include file="public/header" /}
		<div class="index_conbox">
			<div class="index_content clearfix">
				{include file="public/lefter" /}
				<div class="right">
					<div class="rigtop">
						<span class="title">鼓励金营销</span>
					</div>
					<div class="indrig_con" style="position: relative;">
						<div class="zizh_btnbox" style="top: -78px; right: 20px;">
							<button class="zizh_btn" type="button" onclick="helps()">帮助说明</button>
						</div>
						<div class="shxx_item">
							<!--<form class="layui-form">
								<div class="shxx_row clearfix" style="margin-top: 20px;">
									<div class="left">鼓励金营销</div>
									<div class="right">
										<div class="layui-input-block" style="margin-left: 0;">
									      <input disabled type="checkbox" checked name="open" lay-skin="switch" lay-filter="switchTest" lay-text="开启|关闭">
									    </div>
									</div>
								</div>
							</form>-->
							<form class="form form-horizontal" id="form-admin-add" method="post">
								<div class="shxx_row clearfix">
									<div class="left">抵扣比例</div>
									<div class="right">
										<p>
											<span>
											<input type="text" style="width: 30px;" class="chax_input" placeholder="0" id="ad_score" value="{$list.ad_score}" />
											<label>%</label>
										</span>
											<span><a class="edit" id="tijiao1">保存</a></span>
										</p>
									</div>
								</div>
								<!--<div class="shxx_row clearfix">
									<div class="left">赠送比例</div>
									<div class="right">
										<p>
											<span>
											<input type="text" style="width: 30px;" class="chax_input" placeholder="0" id="zs_score" value="{$list.zs_score}"/>
											<label>%</label>
										</span>
											<span><a href="javascipt:;" class="edit" id="tijiao2">保存</a></span>
										</p>
									</div>
								</div>-->
							</form>
							<div class="shxx_row clearfix">
								<div class="left" style="margin-left: 13px;">鼓励金余额</div>
								<div class="right">
									<p>
										<em>{$list.score}元</em>
										<!--<a href="javascript:;" onclick="yue_score()" class="edit">购买</a>-->
										<a href="{:url('index/score_record')}" class="green">记录</a>
									</p>
								</div>
							</div>
						</div>

					</div>
				</div>
			</div>
		</div>

		{include file="public/footer" /}
	</body>

</html>
<script>
layui.use(['form', 'layedit', 'laydate'], function(){
  var form = layui.form

  //监听指定开关
  form.on('switch(switchTest)', function(data){
    layer.tips((this.checked ? '鼓励金营销开启' : '鼓励金营销关闭'), data.othis)
    var checked = this.checked;
    var flag=1;//1开启  2关闭
    if(checked==false){
    	flag=2;
    }
    isscore(flag);
  });
  
  //监听提交
  form.on('submit(demo1)', function(data){
    layer.alert(JSON.stringify(data.field), {
      title: '最终的提交信息'
    })
    return false;
  });
  
  
});
	
</script>
<script>
	function isscore(scoreid) {
		$.ajax({
			type: 'get',
			url: "{:url('Activet/integral_marketing_up')}",
			dataType: 'json',
			data: {
				scoreid: scoreid
			},
			success: function(data) {
				if(data.code == 200) {
//					layer.msg(data.msg, {
//						icon: 1,
//						time: 1000
//					});
					location.reload();
				} else {
					layer.msg(data.msg, {
						icon: 1,
						time: 1000
					});
				}
			}
		});
	}
	$('#tijiao1').click(function() {
		var ad_score = $('#ad_score').val();
		if(ad_score>=100){
			layer.msg('鼓励金抵扣不能超过100');
			return ;
		}
		genxin();
	});
	
	$('#tijiao2').click(function() {
		genxin();
	});

	function genxin() {
		$.ajax({
			type: 'post',
			data: {
				ad_score: $('#ad_score').val() 
			},
			url: "{:url('Activet/integral_marketing')}",
			success: function(data) {
				if(data.code == 200) {
					layer.msg(data.msg, {
						icon: 1,
						time: 1000
					}, function() {
						window.parent.location.reload();
					});
				} else {
					layer.msg(data.msg, {
						icon: 1,
						time: 1000
					});
				}

			}
		});
	}
	//购买鼓励金
	function yue_score() {
		layer.open({
			type: 2,
			title: '购买鼓励金',
			shadeClose: true,
			shade: 0.8,
			area: ['255px', '265px'],
			content: "{:url('index/yue_score')}"
		});
	}
	//帮助
	function helps() {
		layer.open({
			type: 2,
			title: '鼓励金使用帮助',
			shadeClose: true,
			shade: 0.8,
			area: ['1000px', '800px'],
			content: "{:url('activet/help2')}"
		});
	}
</script>